﻿using CheemsControl.Models.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheemsControl.Models
{
    public class SingleMessage
    {
        public SingleMessage()
        {
            this.time = DateTime.Now;
            this.type = AlarmLevel.None;
        }

        /// <summary>
        /// 时间
        /// </summary>
        public DateTime time { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// 提示
        /// </summary>
        public string tips { get; set; }

        /// <summary>
        /// 消息
        /// </summary>
        public string message { get; set; }

        /// <summary>
        /// 消息报警等级
        /// </summary>
        public AlarmLevel type { get; set; }

        // 重写 Equals 方法进行相等比较
        public override bool Equals(object obj)
        {
            if (obj is SingleMessage other)
            {
                return this.time == other.time &&
                       this.tips == other.tips &&
                       this.type == other.type;
            }
            return false;
        }

        // 重写 GetHashCode 方法
        public override int GetHashCode()
        {
            // 结合 time, message 和 type 属性生成唯一的哈希值
            unchecked
            {
                int hash = 17;
                hash = hash * 23 + time.GetHashCode();
                hash = hash * 23 + (tips?.GetHashCode() ?? 0);
                hash = hash * 23 + type.GetHashCode();
                return hash;
            }
        }
    }

}
